package PSQueue;

import Service.Variable;

/**
 * @author cyye
 *
 */
public class PSMessage implements AbstractMessage {

	private String msgName;
	private int msgType;
	private Object value;
	
	public void setMsgName(String msgName) {
		assert msgName!=null;
		this.msgName = msgName;
	}
	
	public String getMsgName() {
		return msgName;
	}

	public void setMsgType(int msgType) {
		assert Variable.validType(msgType);
		this.msgType = msgType;
	}

	public int getMsgType() {
		return msgType;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public Object getValue() {
		return value;
	}
	
	public static AbstractMessage cloneMessage(AbstractMessage msg) {
		assert msg!=null;
		PSMessage result = new PSMessage();
		String name = msg.getMsgName();
		assert name!=null;
		result.setMsgName(name);
		
		int type = msg.getMsgType();
		assert Variable.validType(type);
		result.setMsgType(type);
		
		Object value = msg.getValue();
		result.setValue(value);
		
		return result;
	}
	
}
